package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOperDemo {
    public static void main(String[] args) {
    Collection c=new ArrayList();
    c.add("8");
    c.add("2");
    c.add("1");
        System.out.println(c);

        Collection c1=new ArrayList();
        c1.add("iiii");
        c.addAll(c1);
        System.out.println(c);
        /*
        取c中仅保留与c1所共有的元素,c1不变
        c.retainAll(c1)
         */
        c.retainAll(c1);
        System.out.println(c);
        System.out.println(c1);
        /*
        删交集:将c与c1共有的元素删掉.c1不变
       c.removeAll(c1)
         */
        c.removeAll(c1);
        System.out.println(c);
        /*
        Iterator
         */
    }
}
